﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace bts_webapp
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Common.CurrentUser != null)
            {
                //========== for login page ===================
                if (this.Page is bts_webapp.Account.Login) 
                {
                    Common.CurrentUser = null;
                    Common.PermissionList = null;
                    this.linkLog.Text = "Đăng nhập";
                    this.litFullName.Text = string.Empty;
                    return;
                }

                //=============================================


                this.litFullName.Text = " (" + Common.CurrentUser.User_Full_Name +")";
                this.linkLog.Text = "Đăng xuất";

                //permission
                if (Common.CurrentUser.User_Role == 0)      //admin
                {
                    
                }
                else if (Common.CurrentUser.User_Role == 1) //custom user
                {

                }
                else if (Common.CurrentUser.User_Role == 2) //readonly user
                {
                    //this.RadMenu1.Items[2].Enabled = false;
                }
            }
            else
            {
                this.linkLog.Text = "Đăng nhập";
            }
        }

        protected void linkLog_Click(object sender, EventArgs e)
        {
            Common.CurrentUser = null;     
            Common.PermissionList = null;
            Response.Redirect("~/Login.aspx", true);
        }
    }
}
